﻿using System;
using BlockLogic.Interface;

namespace BlockLogic.Impl
{
    public class Request : IRequest
    {
        public Guid GeneratorID { get; private set; }
        public Guid ServiceDeviceID { get; set; }

        public double InitTime { get; private set; }
        public double ServiceTime { get; set; }

        public double WaitingTime { get; set; }
        public double MaxWaitingTime { get; set; }

        public Request(Guid generatorID, double initTime)
        {
            GeneratorID = generatorID;
            InitTime = initTime;
            MaxWaitingTime = -1;
        }

        public Request(Guid generatorID, double initTime, double maxWaitingTime)
        {
            GeneratorID = generatorID;
            InitTime = initTime;
            MaxWaitingTime = maxWaitingTime;
        }

        public int CompareTo(IRequest other)
        {
            if (this.InitTime < other.InitTime)
            {
                return -1;
            }
            else if (this.InitTime > other.InitTime)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }

        public IRequest Clone()
        {
            Request cloneRequest = new Request(this.GeneratorID, this.InitTime);
            cloneRequest.ServiceDeviceID = this.ServiceDeviceID;
            cloneRequest.ServiceTime = this.ServiceTime;
            cloneRequest.WaitingTime = this.WaitingTime;
            cloneRequest.MaxWaitingTime = this.MaxWaitingTime;
            return cloneRequest;
        }
    }
}
